<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">

    <h:body>
        <ui:composition template="/resources/template/template.xhtml">
            <ui:define name="content">
                <h:form>
                    <p:panel >

                        <f:facet name="header" >
                            <h:outputLabel value="GRN DEALER PAYMENT BILL SEARCH "/>                                                      
                            <h:panelGrid columns="8" >
                                <h:outputLabel value="From Date"/>
                                <p:calendar styleClass="dateTimePicker" id="fromDate" value="#{searchController.fromDate}" navigator="false" pattern="dd MMMM yyyy hh mm ss a" >      
                                </p:calendar>
                                <h:outputLabel value="To Date"/>
                                <p:calendar id="toDate" value="#{searchController.toDate}" navigator="false" pattern="dd MMMM yyyy hh mm ss a" >                                                                              
                                </p:calendar>

                                <p:commandButton id="btnSearch" ajax="false" value="Search Pharmacy Payment" action="#{searchController.createPharmacyPaymentPre()}"/>
                                <p:commandButton ajax="false" value="Search Store Payment" action="#{searchController.createStorePaymentPre()}"/>
                                <p:commandButton ajax="false" value="Search All Payment" action="#{searchController.createStorePaharmacyPaymentPre}"/>
                            </h:panelGrid>

                            <h:panelGrid columns="5">
                                <h:outputLabel value="Bill No"/>
                                <h:outputLabel value="Distributor Name"/>                               
                                <h:outputLabel value="Net Total"/>
                                <h:outputLabel value="Bank"/>
                                <h:outputLabel value="Check No"/>
                                <p:inputText autocomplete="off"  value="#{billSearch.searchKeyword.billNo}" />
                                <p:inputText autocomplete="off" value="#{billSearch.searchKeyword.toInstitution}" />                                
                                <p:inputText autocomplete="off" value="#{billSearch.searchKeyword.netTotal}"/>
                                <p:inputText autocomplete="off" value="#{billSearch.searchKeyword.bank}"/>
                                <p:inputText autocomplete="off" value="#{billSearch.searchKeyword.number}"/>
                            </h:panelGrid>

                        </f:facet>                               



                        <p:dataTable 
                            id="tblBills" 
                            value="#{searchController.bills}" 
                            var="bill"  
                            paginator="true"
                            paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                            rowsPerPageTemplate="5,10,15"
                            >
                            <p:column>
                                <p:commandButton ajax="false" value="Approve" action="reprint_bill_dealor">
                                    <f:setPropertyActionListener value="#{bill}" 
                                                                 target="#{dealorPaymentBillSearch.bill}"/>
                                </p:commandButton>
                            </p:column>                            
                            <p:column headerText="Bill No" >                                
                                <h:outputLabel value="#{bill.insId}"  ></h:outputLabel>                                    
                            </p:column>
                            <p:column headerText="Dealer Name"   >                             
                                <h:outputLabel value="#{bill.toInstitution.name}" />
                            </p:column>                          

                            <p:column headerText="Billed at"  >                                
                                <h:outputLabel value="#{bill.createdAt}" >
                                    <f:convertDateTime pattern="dd/MMM/yyyy - hh:mm:ss a"/>
                                </h:outputLabel>                                    
                                <br/>
                                <h:panelGroup rendered="#{bill.cancelled}" >
                                    <h:outputLabel style="color: red;" value="Cancelled at " />
                                    <h:outputLabel style="color: red;" rendered="#{bill.cancelled}" value="#{bill.cancelledBill.createdAt}" >
                                        <f:convertDateTime pattern="dd/MMM/yyyy - hh:mm:ss a"/>
                                    </h:outputLabel>
                                </h:panelGroup>                                
                            </p:column>  
                            <p:column headerText="Billed by" >                               
                                <h:outputLabel value="#{bill.creater.webUserPerson.name}" >                                      
                                </h:outputLabel>                                    
                                <br/>
                                <h:panelGroup rendered="#{bill.cancelled}" >
                                    <h:outputLabel style="color: red;" value="Cancelled By " />
                                    <h:outputLabel style="color: red;" rendered="#{bill.cancelled}" value="#{bill.cancelledBill.creater.webUserPerson.name}" >                                       
                                    </h:outputLabel>
                                </h:panelGroup>                               
                            </p:column> 

                            <p:column headerText="Payment Method" >                                
                                <h:outputLabel value="#{bill.paymentMethod}" >                                       
                                </h:outputLabel>
                            </p:column>
                            <p:column headerText="Net Value" >                             
                                <h:outputLabel value="#{bill.netTotal}" >
                                    <f:convertNumber pattern="#,##0.00"/>
                                </h:outputLabel>
                            </p:column>
                            <p:column headerText="Bank" >                                
                                <h:outputLabel value="#{bill.bank.name}" >                                        
                                </h:outputLabel>
                            </p:column>
                            <p:column headerText="Cheque No" >                               
                                <h:outputLabel value="#{bill.chequeRefNo}" >                                       
                                </h:outputLabel>
                            </p:column>
                            <p:column headerText="Cheque Date"  >                                
                                <h:outputLabel value="#{bill.chequeDate}" >
                                    <f:convertDateTime pattern="dd MM yyyy"/>
                                </h:outputLabel>
                            </p:column>                           
                            <p:column headerText="Comments" >                                
                                <h:outputLabel  value="#{bill.comments}" >
                                </h:outputLabel>
                            </p:column>
                        </p:dataTable>


                    </p:panel>

                </h:form>
            </ui:define>


        </ui:composition>

    </h:body>
</html>
